package com.example.mydesignmodule.iterator;

/**
 * @author tgw
 * @date 2021/3/3
 * @describe  迭代器模式
 */
class IteratorRunMain {

    public static void main(String[] args) {

        System.out.println("遍历集合");
        IteratorCompany company = new PeopleCompany();
        next(company.itertor());

        System.out.println("遍历数组");
        company = new ArrayPeopleCompany();
        next(company.itertor());
    }

    private static void next(Iterator iterator) {
        while (iterator.hashNext()) {
            System.out.println(iterator.next().toString());
        }
    }


}
